﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;

namespace INTREPWEB.Models
{
    public class ItemViewModel
    {
        public string RE { get; set; }

        [Required]
        public double PesoManifestado { get; set; }

        [Required]
        public double PesoEmbarcado { get; set; }

        public String Unidade { get; set; }

        public  String EmbarqueId { get; set; }

        public int ExportadorId { get; set; }
        public SelectList Exportadores { get; set; }

        public ItemViewModel()
        {

        }

        public ItemViewModel(string id)
        {
            using (INTREPDB db = new INTREPDB())
            {
                EmbarqueId = db.Embarques.Find(id).Id;

                var list = db.Exportadores.ToList()
                    .Select(x => new SelectListItem
                    {
                        Text = x.Nome,
                        Value = x.Id.ToString()
                    });
                Exportadores = new SelectList(list, "Value", "Text");
            }
        }
    }
}